package com.augurit.wf.bi.web;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;

import com.augurit.common.base.action.CrudActionSupport;
import com.augurit.wf.bi.service.IWfTemplateMgmtPrivService;
import com.augurit.wf.bi.web.form.WfTemplateMgmtPrivForm;

@SuppressWarnings("serial")
@Results({
	@Result(name = CrudActionSupport.RELOAD, location = "wf-template-mgmt-priv.action", type = "redirect"),
	@Result(name = CrudActionSupport.SUCCESS, location = "/tt/WfTemplateMgmtPriv/WfTemplateMgmtPriv.jsp"),
	@Result(name = CrudActionSupport.INPUT, location = "/tt/WfTemplateMgmtPriv/WfTemplateMgmtPriv-input.jsp")
})
public class WfTemplateMgmtPrivAction extends CrudActionSupport<WfTemplateMgmtPrivForm>{

	@Autowired
	private IWfTemplateMgmtPrivService wfTemplateMgmtPrivService;

	private WfTemplateMgmtPrivForm form;
	private Long id;
	private Long[] checkedIds;
	private Page<WfTemplateMgmtPrivForm> page = new Page<WfTemplateMgmtPrivForm>(10);


	/**
	 * 分页查询
	 */
	@Override
	public String list() throws Exception {
		wfTemplateMgmtPrivService.search(page, form);
		return SUCCESS;
	}

	/**
	 * 新增或修改
	 */
	@Override
	public String input() throws Exception {
		return INPUT;
	}

	/**
	 * 保存新增或者修改的Form对象
	 */
	@Override
	public String save() throws Exception {
		wfTemplateMgmtPrivService.save(form);
		return RELOAD;
	}

	/**
	 * 删除一条记录
	 */
	@Override
	public String delete() throws Exception {
		wfTemplateMgmtPrivService.delete(id);
		return RELOAD;
	}
	
	/**
	 * 删除多条记录
	 */
	@Override
	public String deleteMore() throws Exception{
		wfTemplateMgmtPrivService.delete(checkedIds);
		return RELOAD;
	}
	
	/**
	 * 准备页面模型
	 */
	@Override
	protected void prepareModel() throws Exception {
		if(id != null){
			form = wfTemplateMgmtPrivService.get(id);
		}
		else
			form = new WfTemplateMgmtPrivForm();
	}
	

	public WfTemplateMgmtPrivForm getModel() {
		return form;
	}
	
	// 属性getter和setter方法
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long[] getCheckedIds() {
		return checkedIds;
	}

	public void setCheckedIds(Long[] checkedIds) {
		this.checkedIds = checkedIds;
	}
	
	public Page<WfTemplateMgmtPrivForm> getPage() {
		return page;
	}


	public void setPage(Page<WfTemplateMgmtPrivForm> page) {
		this.page = page;
	}
}
